package org.me.Slide;



import org.me.Slide.translate3D.Rotate3dAnimation;



import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.widget.ImageView;
import android.widget.LinearLayout;

public class SlideIphoneforAndroidActivity extends Activity {
    /** Called when the activity is first created. */
	LinearLayout mLinearLayout;
	ImageView mImageView;
	Context mContext;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_activity);
        
        mContext = this;
        mLinearLayout = (LinearLayout)findViewById(R.id.linear_main_activity);
        mImageView = (ImageView)findViewById(R.id.image_main_activity);
        
        MainCountDown mCountDown = new MainCountDown(4000,4000);
        mCountDown.start();
        
    }
    
    public class MainCountDown extends CountDownTimer
    {

		public MainCountDown(long millisInFuture, long countDownInterval) {
			super(millisInFuture, countDownInterval);
			// TODO Auto-generated constructor stub
		}

		@Override
		public void onFinish() {
			// TODO Auto-generated method stub
			applyRotation(0, 90);
			
		}

		@Override
		public void onTick(long millisUntilFinished) {
			// TODO Auto-generated method stub
			
		}
    	
    }
    
    private void applyRotation(float start, float end)
    {
    	final float mCenterX = mLinearLayout.getWidth()/2.0f;
    	final float mCenterY = mLinearLayout.getHeight()/2.0f;
    	final Rotate3dAnimation rotation = new Rotate3dAnimation(start, end, mCenterX, mCenterY, 310.0f, true);
    	rotation.setDuration(700);
    	rotation.setFillAfter(true);
    	rotation.setInterpolator(new AccelerateInterpolator());
        rotation.setAnimationListener(new DisplayNextView());
        mLinearLayout.startAnimation(rotation);
    }
    
    public class DisplayNextView implements Animation.AnimationListener
    {

		public void onAnimationEnd(Animation animation) {
			// TODO Auto-generated method stub
			mLinearLayout.post(new SwapsView());
		}

		public void onAnimationRepeat(Animation animation) {
			// TODO Auto-generated method stub
			
		}

		public void onAnimationStart(Animation animation) {
			// TODO Auto-generated method stub
			
		}
    	
    }
    
    private final class  SwapsView implements Runnable
    {

		public void run() {
			// TODO Auto-generated method stub
			Intent mIntent = new Intent(mContext, AlbumListActivity.class);
			startActivity(mIntent);
			finish();
		}
    	
    }
}